package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.financing.wap.common.BizEnums.CommonEnums;
import com.financing.wap.dao.ISalesPrizesLogDao;
import com.financing.wap.dto.SalesPrizesLogDTO;
import com.financing.wap.service.ISalesPrizesLogService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * sales_prizes_log  
 * 抽奖记录 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Repository("salesPrizesLogService")
public class SalesPrizesLogServiceImpl implements ISalesPrizesLogService{

	@Autowired
	private ISalesPrizesLogDao salesPrizesLogDao;

	@Override
	public int insert(SalesPrizesLogDTO salesPrizesLog) throws SQLException {
		DTOdateSetUtil.setCreateInfo(salesPrizesLog);
		DTOdateSetUtil.setUpdateInfo(salesPrizesLog);
		salesPrizesLog.setDeleteTag(CommonEnums.DELETE_FLAG_1);
		return salesPrizesLogDao.insert(salesPrizesLog);
	}

	@Override
	public void update(SalesPrizesLogDTO salesPrizesLog) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(salesPrizesLog);
		salesPrizesLogDao.update(salesPrizesLog);
	}

	@Override
	public void updateForce(SalesPrizesLogDTO salesPrizesLog) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(salesPrizesLog);
		salesPrizesLogDao.updateForce(salesPrizesLog);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		salesPrizesLogDao.delete(id);
	}
	
	@Override
	public List<SalesPrizesLogDTO> queryList(SalesPrizesLogDTO salesPrizesLog) throws SQLException {
		return salesPrizesLogDao.queryList(salesPrizesLog);
	}

	@Override
	public int queryListCount(SalesPrizesLogDTO salesPrizesLog) throws SQLException {
		return salesPrizesLogDao.queryListCount(salesPrizesLog);
	}

	@Override
	public SalesPrizesLogDTO loadById(Integer id) throws SQLException {
		return salesPrizesLogDao.loadById(id);
	}
 	@Override
	public SalesPrizesLogDTO queryListGetFirst(SalesPrizesLogDTO salesPrizesLog)
			throws SQLException {
		 List<SalesPrizesLogDTO> queryList = queryList(salesPrizesLog);
		 if(queryList==null||queryList.size()==0){
			 return new SalesPrizesLogDTO();
		 }
		 return queryList.get(0);
	}
}
